package com.business.service.${pack};

import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.PropertyFilter;
import com.business.dao.${pack}.${clazz}Dao;
import com.business.entity.${pack}.${clazz};

@Component
@Transactional
public class ${clazz}Service {
	private static Logger logger = LoggerFactory.getLogger(${clazz}Service.class);
	private ${clazz}Dao ${object}Dao;
	
	/**
	 * get object by id
	 */
	@Transactional(readOnly = true)
	public ${clazz} get${clazz}(Long id) {
		return ${object}Dao.get(id);
	}

	/**
	 * update or save object
	 * @param entity
	 */
	public void save${clazz}(${clazz} entity) {
		${object}Dao.save(entity);
	}
	
	/**
	 * delete object
	 */
	public void delete${clazz}(Long id) {
		${object}Dao.delete(id);
	}
	
	/**
	 * find object by filters
	 */
	@Transactional(readOnly = true)
	public Page<${clazz}> search${clazz}(final Page<${clazz}> page, final List<PropertyFilter> filters) {
		return ${object}Dao.findPage(page, filters);
	}
	
	public static Logger getLogger() {
		return logger;
	}
	public static void setLogger(Logger logger) {
		${clazz}Service.logger = logger;
	}
	
	@Autowired
	public void set${clazz}Dao(${clazz}Dao ${object}Dao) {
		${object}Dao = ${object}Dao;
	}
	
	
	
}
